/*
package com.other;

import javafx.scene.layout.VBox;

public class FractionDemo {
    private int numerator;
    private int denominator;

    public FractionDemo(int numerator, int denominator) {
        VBox box = new VBox();
        if (denominator == 0) {
            throw new IllegalArgumentException("Denominator cannot be zero.");
        }
        this.numerator = numerator;
        this.denominator = denominator;
        normalize();
    }

    // 做加法
    public FractionDemo add(FractionDemo other) {
        int newNumerator = this.numerator * other.denominator + other.numerator * this.denominator;
        int newDenominator = this.denominator * other.denominator;
        return new FractionDemo(newNumerator, newDenominator);
    }

    // 做减法
    public FractionDemo subtract(FractionDemo other) {
        int newNumerator = this.numerator * other.denominator - other.numerator * this.denominator;
        int newDenominator = this.denominator * other.denominator;
        return new FractionDemo(newNumerator, newDenominator);
    }

    // 做乘法
    public FractionDemo multiply(FractionDemo other) {
        int newNumerator = this.numerator * other.numerator;
        int newDenominator = this.denominator * other.denominator;
        return new FractionDemo(newNumerator, newDenominator);
    }

    // 做除法
    public FractionDemo divide(FractionDemo other) {
        if (other.numerator == 0) {
            throw new ArithmeticException("Cannot divide by zero fraction.");
        }
        int newNumerator = this.numerator * other.denominator;
        int newDenominator = this.denominator * other.numerator;
        return new FractionDemo(newNumerator, newDenominator);
    }

    // 归一化方法
    private void normalize() {
        int gcd = gcd(Math.abs(this.numerator), Math.abs(this.denominator));
        this.numerator /= gcd;
        this.denominator /= gcd;
        if (this.denominator < 0) {
            this.numerator = -this.numerator;
            this.denominator = -this.denominator;
        }
    }

    // 求最大公约数
    private int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    @Override
    public String toString() {
        if (denominator == 1) {
            return Integer.toString(numerator);
        }
        return numerator + "/" + denominator;
    }

    public static void main(String[] args) {
        FractionDemo fractionDemo1 = new FractionDemo(1, 2);
        FractionDemo fractionDemo2 = new FractionDemo(1, 4);

        System.out.println("Fraction 1: " + fractionDemo1);
        System.out.println("Fraction 2: " + fractionDemo2);

        System.out.println("add: " + fractionDemo1.add(fractionDemo2));
        System.out.println("subtract: " + fractionDemo1.subtract(fractionDemo2));
        System.out.println("multiply: " + fractionDemo1.multiply(fractionDemo2));
        System.out.println("divide: " + fractionDemo1.divide(fractionDemo2));
    }
}*/
